package com.keggview.application.xml.datatypes;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;

//import org.dom4j.Element;

/**
 * The product element specifies the product node of this reaction. The
 * attribute of this element is as follows.
 * 
 * @author Pablo
 * 
 */
@XStreamAlias("product")
public class Product extends Base {

	/**
	 * The name attribute contains the KEGG identifier of the COMPOUND database
	 * or the GLYCAN database.
	 */
	@XStreamAsAttribute
	String name;
	
	private Alt alt;

	private Entry product;
	
	/**
	 * @param name
	 */
	public Product(String name) {
		super();
		this.name = name;
		this.alt = null;
		this.product = null;
		Registry.register(this);
	}

//	public Product(Element element) {
//
//		this.name = element.attribute("name").getValue();
//	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the alt
	 */
	public Alt getAlt() {
		return alt;
	}

	/**
	 * @param alt the alt to set
	 */
	public void setAlt(Alt alt) {
		this.alt = alt;
	}

	/**
	 * @return the product
	 */
	public Entry getProduct() {
		if (product == null) {
			this.product = Registry.nEntries.get(this.getName());
		}
		return product;
	}

	/**
	 * @param product the product to set
	 */
	public void setProduct(Entry product) {
		this.product = product;
		this.name = product.getName();
	}

	
}
